import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'
import WeatherPage from '../views/WeatherPage.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      redirect: '/weather'
    },
    {
      path: '/weather',
      name: 'home',
      meta: { showFather: true }, // 默认显示一级路由
      component: HomeView
    },
    {
      path: '/weather/:cityName',
      name: 'weather',
      meta: { showFather: true }, // 默认显示一级路由
      component: WeatherPage
      // children: [
      //   {
      //     path: ':cityName',
      //     name: 'weather',
      //     meta: { showFather: false }, // 隐藏一级路由
      //     component: () => import('../views/WeatherPage.vue')
      //   }
      // ]
    }
  ]
})

export default router
